<?php
/*
 * @Author: your name
 * @Date: 2021-11-02 19:06:50
 * @LastEditTime: 2022-02-10 10:42:11
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: /nlog/app/Models/admin_model/Admin.php
 */

namespace App\Models\admin_model;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;

class OperationLog extends Model
{
    use HasFactory;
    static string $tableName = 'operation_log';

    // public static function operationLogList($formData)
    // {
    //     return DB::table(self::$tableName)->insert($formData);
    // }

    // public static function checkUserName($userName){
    //     return Db::table(self::$tableName)->where(['userName'=>$userName,'delete_time'=>null])->select('id')->first();
    // }

    public static function list($whereStr = '', $limitStr = '')
    { 
        return DB::select(' SELECT `operation_log`.*,`admins`.`userName`,`admins`.`nickName`,`admins`.`realName` FROM `'.self::$tableName.'` as `operation_log` LEFT JOIN `admins` ON `operation_log`.`operation_id` = `admins`.`id` '.$whereStr.' ORDER BY `operation_log`.`id` DESC   '.$limitStr);
    }
    

    public static function count($whereStr = '')
    {
        return DB::select(' SELECT COUNT(*) as `count` FROM `'.self::$tableName.'` as `operation_log` LEFT JOIN `admins` ON `operation_log`.`operation_id` = `admins`.`id` '.$whereStr);
    }

   
}
